package com.victor.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.victor.entity.Age;
import com.victor.entity.Banner;
import com.victor.entity.BannerToGrowplan;

@Mapper
public interface BannerDao {
	/**
	 * 获取banner图列表
	 * 
	 * @return
	 */
	@Select({ "select * from banner" })
	List<Banner> getAllBanner();

	/**
	 * 通过bannerid获取banner详情
	 * 
	 * @param bannerid
	 * @return
	 */
	@Select({ "select * from banner where id=#{bannerid}" })
	Banner getBannerXqByid(@Param("bannerid") String bannerid);

	/**
	 * 获取年龄段列表
	 * 
	 * @return
	 */
	@Select({ "select a_id aId,a_context aContext from age" })
	List<Age> getAllAgeList();

	/**
	 * 用bannerid和ageid查询绘本列表和年龄段关系
	 * 
	 * @param bannerid
	 * @param ageid
	 * @return
	 */
	List<BannerToGrowplan> getPicturebookByBannerAndAge(@Param("bannerid") String bannerid,
			@Param("ageid") String ageid);

	/**
	 * 通过四个参数去查询是否有数据
	 * 
	 * @param bannerToGrowplan
	 * @return
	 */
	@Select({
			"select * from bannertogrowplan where month=#{month} and  bannerid=#{bannerid} and ageid=#{ageid} and picturebookid=#{picturebookid}" })
	BannerToGrowplan getBannerToGrowplanByAll(BannerToGrowplan bannerToGrowplan);

	/**
	 * 添加绘本 传添加到那个年龄,添加的banner图,添加的月份,图书id
	 * 
	 * @param bannerToGrowplan
	 * @return
	 */
	@Insert({
			"insert into bannertogrowplan (month,bannerid,ageid,picturebookid) values (#{month},#{bannerid},#{ageid},#{picturebookid})" })
	int addBannerPicture(BannerToGrowplan bannerToGrowplan);

	/**
	 * 删除banner中绘本
	 * 
	 * @param bannertogrowplanid
	 * @return
	 */
	@Delete({ "delete from bannertogrowplan where id=#{bannertogrowplanid}" })
	int delBannerPicturebook(@Param("bannertogrowplanid") Integer bannertogrowplanid);

	/**
	 * 批量删除 通过id数组
	 * 
	 * @param ids
	 * @return
	 */
	int delBannerPicturebookByids(@Param("ids") int ids);

	/**
	 * 修改banner信息
	 * 
	 * @param banner
	 * @return
	 */
	int updateBanner(Banner banner);

}
